/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dpy.appmvdpy.Models.Exporters;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ac_psoares
 */
public abstract class Exporter<T> {
    
    public File out;
    public FileWriter writer;
    public BufferedWriter bWriter;
    public RandomAccessFile ffile;
    
    protected Exporter()
    {
    
    }
    
    public Exporter(File file) 
    {
        try {
            out = file;
          //  ffile = new RandomAccessFile(out, "rw");
            writer = new FileWriter(file);
            bWriter = new BufferedWriter(writer);
        } catch (IOException ex) {
            Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex);
        }
     //  bWriter = new BufferedWriter(writer);
    }
    
    public abstract File doExport(List<T> items);
    
    public void setFile(File file)
    {
     try {
            out = file;
          //  ffile = new RandomAccessFile(out, "rw");
            writer = new FileWriter(file);
            bWriter = new BufferedWriter(writer);
        } catch (IOException ex) {
            Logger.getLogger(Exporter.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
